home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / Found / FWExcLib / Sources / FWExcept.cpp < prev    next >
Encoding:
Text File  |  1995-11-08  |  3.0 KB  |  104 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWExcept.cpp
  4. //    Release Version:    $ 1.0d11 $
  5. //
  6. //    Copyright:    (c) 1993, 1995 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #include "FWFound.hpp"
  11.  
  12. #ifndef   FWEXCEPT_H
  13. #include "FWExcept.h"
  14. #endif
  15.  
  16. #ifndef   FWPRIMEM_H
  17. #include "FWPriMem.h"
  18. #endif
  19.  
  20. #ifndef   FWPRIDEB_H
  21. #include "FWPriDeb.h"
  22. #endif
  23.  
  24. #include <stddef.h>
  25.  
  26. #if FW_LIB_EXPORT_PRAGMAS
  27. #pragma lib_export on
  28. #endif
  29.  
  30. #ifdef FW_BUILD_MAC
  31. #pragma segment BEL
  32. #endif
  33.  
  34. //========================================================================================
  35. // CLASS _FW_XException
  36. //========================================================================================
  37.  
  38. FW_DEFINE_EXCEPTION_ROOT(_FW_XException)
  39.  
  40. //----------------------------------------------------------------------------------------
  41. // _FW_XException::operator new
  42. //----------------------------------------------------------------------------------------
  43.  
  44. void* _FW_XException::operator new(size_t    /* size */)
  45. {
  46.     FW_PRIV_ASSERT(FALSE);        // exceptions should be on the stack
  47.     return NULL;
  48. }
  49.  
  50. //----------------------------------------------------------------------------------------
  51. // _FW_XException::operator delete
  52. //----------------------------------------------------------------------------------------
  53.  
  54. void _FW_XException::operator delete(void* /* memory */)
  55. {
  56.     FW_PRIV_ASSERT(FALSE);        // exceptions should be on the stack
  57. }
  58.  
  59. //----------------------------------------------------------------------------------------
  60. // _FW_XException::_FW_XException
  61. //----------------------------------------------------------------------------------------
  62. _FW_XException::_FW_XException()
  63. {
  64. #ifdef FW_DEBUG
  65.     fIsValid = 1;
  66. #endif
  67. }
  68.  
  69. //----------------------------------------------------------------------------------------
  70. // _FW_XException::~_FW_XException
  71. //----------------------------------------------------------------------------------------
  72. _FW_XException::~_FW_XException()
  73. {
  74. #ifdef FW_DEBUG
  75.     FW_PRIV_ASSERT(fIsValid==1);
  76.     fIsValid = 0;
  77. #endif
  78. }
  79.  
  80. #ifndef FW_NATIVE_EXCEPTIONS
  81.  
  82. //----------------------------------------------------------------------------------------
  83. // _FW_XException::PrivIsKindOf()
  84. //----------------------------------------------------------------------------------------
  85.  
  86. int _FW_XException::PrivIsKindOf(FW_ClassInfoPtr  aClass)
  87. {
  88.     FW_PRIV_ASSERT(fIsValid==1);
  89.     return PrivVirtualGetClassInfo()->IsKindOf(aClass);
  90. }
  91.  
  92. #endif // FW_NATIVE_EXCEPTIONS
  93.  
  94. //----------------------------------------------------------------------------------------
  95. // _FW_XException::Copy(void *p)
  96. //----------------------------------------------------------------------------------------
  97. void _FW_XException::Copy(void *p, size_t maxObjectSize) const
  98. {
  99.     FW_PRIV_ASSERT(fIsValid == 1);
  100.     size_t objectSize = GetSize();
  101.     FW_PRIV_ASSERT(objectSize <= maxObjectSize);
  102.     FW_PrimitiveCopyMemory(this, p, objectSize);
  103. }
  104.